{include file="../../../application/admin/view_new/public/head" /}
<script type="text/javascript" src="__STATIC__/js/jquery.jscolor.js"></script>
{include file="../../../application/admin/view_new/public/editor" flag="manga_editor"/}

<div class="page-container p10">
    <div class="showpic" style="display:none;"><img class="showpic_img" width="120" height="160" referrerPolicy="no-referrer"></div>

    <form class="layui-form layui-form-pane" method="post" action="">
        <input type="hidden" name="manga_id" value="{$info.manga_id}">

        <div class="layui-tab">
            <ul class="layui-tab-title ">
                <li class="layui-this">{:lang('base_info')}</a></li>
                <li>漫画数据</a></li>
                <li>{:lang('other_info')}</li>
            </ul>
            <div class="layui-tab-content">

                <div class="layui-tab-item layui-show">

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('param')}：</label>
                        <div class="layui-input-inline w150">
                            <select name="type_id" lay-filter="type_id">
                                <option value="">{:lang('select_type')}</option>
                                {volist name="type_tree" id="vo"}
                                {if condition="$vo.type_mid eq 12"}
                                <option value="{$vo.type_id}" {if condition="$info.type_id eq $vo.type_id"}selected{/if}>{$vo.type_name}</option>
                                {volist name="$vo.child" id="ch"}
                                <option value="{$ch.type_id}" {if condition="$info.type_id eq $ch.type_id"}selected{/if}>&nbsp;|&nbsp;&nbsp;&nbsp;|—{$ch.type_name}</option>
                                {/volist}
                                {/if}
                                {/volist}
                            </select>
                        </div>
                        <div class="layui-input-inline w150">
                            <select name="manga_level">
                                <option value="0">{:lang('select_level')}</option>
                                <option value="9" {if condition="$info.manga_level eq 9"}selected{/if}>{:lang('level')}9-{:lang('slide')}</option>
                                <option value="1" {if condition="$info.manga_level eq 1"}selected{/if}>{:lang('level')}1</option>
                                <option value="2" {if condition="$info.manga_level eq 2"}selected{/if}>{:lang('level')}2</option>
                                <option value="3" {if condition="$info.manga_level eq 3"}selected{/if}>{:lang('level')}3</option>
                                <option value="4" {if condition="$info.manga_level eq 4"}selected{/if}>{:lang('level')}4</option>
                                <option value="5" {if condition="$info.manga_level eq 5"}selected{/if}>{:lang('level')}5</option>
                                <option value="6" {if condition="$info.manga_level eq 6"}selected{/if}>{:lang('level')}6</option>
                                <option value="7" {if condition="$info.manga_level eq 7"}selected{/if}>{:lang('level')}7</option>
                                <option value="8" {if condition="$info.manga_level eq 8"}selected{/if}>{:lang('level')}8</option>
                            </select>
                        </div>
                        <div class="layui-input-inline w150">
                            <select name="manga_status">
                                <option value="1" {if condition="$info.manga_status eq 1"}selected{/if}>{:lang('reviewed')}</option>
                                <option value="0" {if condition="$info.manga_status eq '0'"}selected{/if}>{:lang('reviewed_not')}</option>
                            </select>
                        </div>
                        <div class="layui-input-inline w150">
                            <select name="manga_lock">
                                <option value="0">{:lang('unlock')}</option>
                                <option value="1" {if condition="$info.manga_lock eq 1"}selected{/if}>{:lang('lock')}</option>
                            </select>
                        </div>
                        <div class="layui-input-inline">
                            <input type="checkbox" name="uptime" title="{:lang('update_time')}" value="1" checked class="layui-checkbox checkbox-ids" lay-skin="primary">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('name')}：</label>
                        <div class="layui-input-inline w500">
                            <input type="text" class="layui-input" value="{$info.manga_name}" placeholder="" name="manga_name">
                        </div>
                        <label class="layui-form-label">{:lang('sub')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_sub}" placeholder="" name="manga_sub">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('en')}：</label>
                        <div class="layui-input-inline w500">
                            <input type="text" class="layui-input" value="{$info.manga_en}" placeholder="" name="manga_en">
                        </div>
                        <label class="layui-form-label">{:lang('letter')}：</label>
                        <div class="layui-input-inline w70">
                            <input type="text" class="layui-input" value="{$info.manga_letter}" placeholder="" name="manga_letter">
                        </div>
                        <label class="layui-form-label">{:lang('color')}：</label>
                        <div class="layui-input-inline w70">
                            <input type="text" class="layui-input color" value="{$info.manga_color}" placeholder="" name="manga_color">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">TAG：</label>
                        <div class="layui-input-inline w500">
                            <input type="text" class="layui-input" value="{$info.manga_tag}" placeholder="" name="manga_tag">
                        </div>
                        <div class="layui-input-inline w120">
                            <input type="checkbox" name="uptag" title="{:lang('auto_make')}" value="1" class="layui-checkbox checkbox-ids" lay-skin="primary">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('remarks')}：</label>
                        <div class="layui-input-inline w500">
                            <input type="text" class="layui-input" value="{$info.manga_remarks}" placeholder="例如：更新至20话" name="manga_remarks">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('rel_vod')}：</label>
                        <div class="layui-input-inline w500">
                            <input type="text" class="layui-input" value="{$info.manga_rel_vod}" placeholder="{:lang('admin/vod/rel_vod_tip')}" name="manga_rel_vod">
                        </div>
                        <div class="layui-input-inline ">
                            <a class="layui-btn j-iframe" data-href="{:url('vod/data')}?select=1&input=manga_rel_vod" href="javascript:;" title="{:lang('search_data')}">{:lang('search_data')}</a>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">关联漫画：</label>
                        <div class="layui-input-inline w500">
                            <input type="text" class="layui-input" value="{$info.manga_rel_manga}" placeholder="请填写关联漫画ID,多个用,号连接" name="manga_rel_manga">
                        </div>
                        <div class="layui-input-inline ">
                            <a class="layui-btn j-iframe" data-href="{:url('manga/data')}?select=1&input=manga_rel_manga" href="javascript:;" title="{:lang('search_data')}">{:lang('search_data')}</a>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('class')}：</label>
                        <div class="layui-input-inline w500">
                            <input type="text" class="layui-input" value="{$info.manga_class}" placeholder="" id="manga_class" name="manga_class">
                        </div>
                        <div class="layui-input-inline w500 manga_class_label">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('pic')}：</label>
                        <div class="layui-input-inline w500 upload">
                            <input type="text" class="layui-input upload-input" style="max-width:100%;" value="{$info.manga_pic}" placeholder="" id="manga_pic" name="manga_pic">
                        </div>
                        <div class="layui-input-inline ">
                            <button type="button" class="layui-btn layui-upload" lay-data="{data:{thumb:1,thumb_class:'upload-thumb'}}" id="upload1">{:lang('upload_pic')}</button>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('pic_thumb')}：</label>
                        <div class="layui-input-inline w500 upload">
                            <input type="text" class="layui-input upload-input" style="max-width:100%;" value="{$info.manga_pic_thumb}" placeholder="" id="manga_pic_thumb" name="manga_pic_thumb">
                        </div>
                        <div class="layui-input-inline ">
                            <button type="button" class="layui-btn layui-upload" lay-data="{data:{thumb:0,thumb_class:'upload-thumb'}}" id="upload2">{:lang('upload_pic')}</button>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('pic_slide')}：</label>
                        <div class="layui-input-inline w500 upload">
                            <input type="text" class="layui-input upload-input" style="max-width:100%;" value="{$info.manga_pic_slide}" placeholder="" id="manga_pic_slide" name="manga_pic_slide">
                        </div>
                        <div class="layui-input-inline ">
                            <button type="button" class="layui-btn layui-upload" lay-data="{data:{thumb:0,thumb_class:'upload-thumb'}}" id="upload3">{:lang('upload_pic')}</button>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('blurb')}：</label>
                        <div class="layui-input-block">
                            <textarea name="manga_blurb" cols="" rows="3" class="layui-textarea"  placeholder="{:lang('blurb_auto_tip')}" style="height:40px;">{$info.manga_blurb}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">漫画简介：</label>
                        <div class="layui-input-block">
                            <textarea class="layui-textarea" id="manga_content" name="manga_content" type="text/plain" style="width:100%;height:250px">{$info.manga_content|mac_url_content_img}</textarea>
                        </div>
                    </div>

                </div>

                <div class="layui-tab-item">
                    <div class="layui-form-item">
                        <label class="layui-form-label">章节来源：</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" value="{$info.manga_chapter_from}" placeholder="例如：tkmh$$$manhuagui" name="manga_chapter_from">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">章节列表：</label>
                        <div class="layui-input-block">
                            <textarea name="manga_chapter_url" class="layui-textarea" placeholder="格式：第1话$https://img.xxx.com/1.jpg,https://img.xxx.com/2.jpg#第2话$https://img.xxx.com/3.jpg" style="height:300px;">{$info.manga_chapter_url}</textarea>
                        </div>
                    </div>
                </div>

                <div class="layui-tab-item">
                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('up')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_up}" placeholder="" id="manga_up" name="manga_up">
                        </div>
                        <label class="layui-form-label">{:lang('hate')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_down}" placeholder="" id="manga_down" name="manga_down">
                        </div>
                        <button class="layui-btn" type="button" id="btn_rnd">{:lang('rnd_make')}</button>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('hits')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_hits}" placeholder="" id="manga_hits" name="manga_hits">
                        </div>
                        <label class="layui-form-label">{:lang('hits_month')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_hits_month}" placeholder="" id="manga_hits_month" name="manga_hits_month" >
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('hits_week')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_hits_week}" placeholder="" id="manga_hits_week" name="manga_hits_week">
                        </div>
                        <label class="layui-form-label">{:lang('hits_day')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input " value="{$info.manga_hits_day}" placeholder="" id="manga_hits_day" name="manga_hits_day">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('score')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_score}" placeholder="" id="manga_score" name="manga_score">
                        </div>
                        <label class="layui-form-label">{:lang('score_all')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_score_all}" placeholder="" id="manga_score_all" name="manga_score_all">
                        </div>
                        <label class="layui-form-label">{:lang('score_num')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_score_num}" placeholder="" id="manga_score_num" name="manga_score_num">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('points_all')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_points}" placeholder="" name="manga_points">
                        </div>
                        <label class="layui-form-label">{:lang('points_detail')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_points_detail}" placeholder="" name="manga_points_detail">
                        </div>
                        <label class="layui-form-label">{:lang('tpl')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_tpl}" placeholder="" name="manga_tpl">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('author')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_author}" placeholder="" name="manga_author">
                        </div>
                        <label class="layui-form-label">{:lang('from')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_from}" placeholder="" name="manga_from">
                        </div>
                        <label class="layui-form-label">{:lang('jumpurl')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_jumpurl}" placeholder="" name="manga_jumpurl">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">{:lang('access_pwd')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_pwd}" placeholder="{:lang('not_static_is_ok')}" name="manga_pwd">
                        </div>
                        <label class="layui-form-label">{:lang('pwd_url')}：</label>
                        <div class="layui-input-inline ">
                            <input type="text" class="layui-input" value="{$info.manga_pwd_url}" placeholder="" name="manga_pwd_url">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item center">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="formSubmit" data-child="">{:lang('btn_save')}</button>
                <button class="layui-btn layui-btn-primary" type="reset">{:lang('btn_reset')}</button>
            </div>
        </div>
    </form>
</div>
{include file="../../../application/admin/view_new/public/foot" /}

<script type="text/javascript">
    var UPLOAD_IMG_KEY="{$GLOBALS['config']['upload']['img_key']}";
    var UPLOAD_IMG_API="{$GLOBALS['config']['upload']['img_api']}";
    var editor = editor_getEditor('manga_content');

    layui.use(['form','upload', 'layer'], function () {
        // 操作对象
        var form = layui.form, layer = layui.layer, $ = layui.jquery, upload = layui.upload;

        // 验证
        form.verify({
            manga_name: function (value) {
                if (value == "") {
                    return "{:lang('name_empty')}";
                }
            }
        });

        $(document).on("click", ".extend", function(){
            $id = $(this).attr('data-id');
            if($id == 'manga_class'||$id == 'manga_keywords'){
                $val = $("input[id='"+$id+"']").val();
                if($val!=''){$val = $val+',';}
                if($val && $val.indexOf($(this).text())>-1){return;}
                $("input[id='"+$id+"']").val($val+$(this).text());
            }else{
                $("input[id='"+$id+"']").val($(this).text());
            }
        });

        form.on('select(type_id)', function(data){
            getExtend(data.value);
        });

        upload.render({
            elem: '.layui-upload'
            ,url: "{:url('upload/upload')}?flag=manga"
            ,method: 'post'
            ,before: function(input) {
                layer.msg("{:lang('upload_ing')}", {time:3000000});
            },done: function(res, index, upload) {
                var obj = this.item;
                if (res.code == 0) {
                    layer.msg(res.msg);
                    return false;
                }
                layer.closeAll();
                var input = $(obj).parent().parent().find('.upload-input');
                if ($(obj).attr('lay-type') == 'image') {
                    input.siblings('img').attr('src', res.data.file).show();
                }
                input.val(res.data.file);

                if(res.data.thumb_class !=''){
                    $('.'+ res.data.thumb_class).val(res.data.thumb[0].file);
                }
            }
        });

        $('.upload-input').hover(function (e){
            var e = window.event || e;
            var imgsrc = $(this).val();
            if(imgsrc.trim()==""){ return; }
            var left = e.clientX+document.body.scrollLeft+20;
            var top = e.clientY+document.body.scrollTop+20;
            $(".showpic").css({left:left,top:top,display:""});
            if(imgsrc.indexOf('://')<0){ imgsrc = ROOT_PATH + '/' + imgsrc;	} else{ imgsrc = imgsrc.replace('mac:','http:'); }
            $(".showpic_img").attr("src", imgsrc);
        },function (e){
            $(".showpic").css("display","none");
        });

        $("#btn_rnd").click(function(){
            $("#manga_hits").val( rndNum(5000,9999) );
            $("#manga_hits_month").val( rndNum(1000,4999) );
            $("#manga_hits_week").val( rndNum(300,999) );
            $("#manga_hits_day").val( rndNum(1,299) );
            $("#manga_up").val( rndNum(1,999) );
            $("#manga_down").val( rndNum(1,999) );
            $("#manga_score").val( rndNum(10) );
            $("#manga_score_all").val( rndNum(1000) );
            $("#manga_score_num").val( rndNum(100) );
        });
    });

    function getExtend(id){
        $.post("{:url('type/extend')}", {id:id}, function(res) {
            if (res.code == 1) {
                $.each(res.data, function(key, value){
                    $('.manga_'+key+"_label").html('');
                    if(value != ''){
                        $.each(value, function(key2, value2){
                            $(".manga_"+key+"_label").append('<a class="layui-btn layui-btn-xs extend" href="javascript:;" data-id="manga_'+key+'">'+value2+'</a>');
                        });
                    }
                });
            }
        });
    }

    {if condition="$info.manga_id gt 0"}
    setTimeout(function () {
        getExtend('{$info.type_id}')
    },1000);
    {/if}
</script>

</body>
</html>
